package com.vvvtimes.demo.controller;

import com.vvvtimes.demo.common.dto.RestResponse;
import com.vvvtimes.demo.domain.dto.DecoderDTO;
import com.vvvtimes.demo.domain.dto.EncoderDTO;
import com.vvvtimes.demo.domain.dto.UrlDecoderDTO;
import com.vvvtimes.demo.service.DecoderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/decoder")
public class DecoderController {

    @Autowired
    private DecoderService decoderService;

    @RequestMapping(value = "/base64Decoder", method = {RequestMethod.POST, RequestMethod.GET})
    public RestResponse<String> base64Decoder(@RequestBody DecoderDTO decoderDTO) {
        return decoderService.base64Encoder(decoderDTO);
    }

    @RequestMapping(value = "/urlDecoder", method = {RequestMethod.POST, RequestMethod.GET})
    public RestResponse<String> urlDecoder(@RequestBody UrlDecoderDTO decoderDTO) {
        return decoderService.urlDecoder(decoderDTO);
    }

    @RequestMapping(value = "/qrDecoder", method = {RequestMethod.POST, RequestMethod.GET})
    public RestResponse<String> qrDecoder(@RequestParam("file") MultipartFile file) {
        return decoderService.qrDecoder(file);
    }

}

